﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Billing.WindowsBase.CustomControls
{
    [ComplexBindingProperties("DataSource", "DataMember")]
    [ToolboxItem(true)]
    [ToolboxBitmap(typeof(Infragistics.Win.UltraWinGrid.UltraGrid))]
    public partial class sbListGrid : BaseControl
    {
        public sbListGrid()
        {
            InitializeComponent();
        }

        public event Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler InitializeLayout;
        [DefaultValue(false)]
        public bool GroupingHiden
        {
            get { return this.grd.DisplayLayout.GroupByBox.Hidden; }
            set { this.grd.DisplayLayout.GroupByBox.Hidden = value; }
        }

        [DefaultValue(false)]
        public bool EmptyRowHiden
        {
            get { return !this.grd.DisplayLayout.EmptyRowSettings.ShowEmptyRows; }
            set { this.grd.DisplayLayout.EmptyRowSettings.ShowEmptyRows = !value; }
        }

        [DefaultValue(Infragistics.Win.DefaultableBoolean.Default)]
        public Infragistics.Win.DefaultableBoolean RowSelectorHide
        {
            get { return this.grd.DisplayLayout.Override.RowSelectors; }
            set { this.grd.DisplayLayout.Override.RowSelectors = value; }
        }

        [DefaultValue(Infragistics.Win.DefaultableBoolean.Default)]
        public Infragistics.Win.DefaultableBoolean AllowRowFilter
        {
            get { return this.grd.DisplayLayout.Override.AllowRowFiltering; }
            set { this.grd.DisplayLayout.Override.AllowRowFiltering = value; }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public Infragistics.Win.UltraWinGrid.ColumnsCollection Columns
        {
            get
            {
                try
                {
                    return this.grd.DisplayLayout.Bands[0].Columns;
                }
                catch (Exception ex)
                {

                    throw ex;
                }
            }
        }



        [DefaultValue(null), RefreshProperties(RefreshProperties.All)]
        [AttributeProvider(typeof(IListSource))]
        public object DataSource
        {
            get
            { return this.BindingSource.DataSource; }
            set
            {
                try
                {
                    this.BindingSource.DataSource = value;
                }
                catch (Exception ex)
                {

                    throw ex;
                }
            }
        }
        [
DefaultValue(""),
Editor("System.Windows.Forms.Design.DataMemberListEditor, System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing"),
RefreshProperties(RefreshProperties.All)]
        public string DataMember
        {
            get
            { return this.BindingSource.DataMember; }
            set
            {
                try
                {
                    this.BindingSource.DataMember = value;
                }
                catch (Exception ex)
                {

                    throw ex;
                }

            }
        }

        private void grd_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            try
            {
                if (!this.DesignMode)
                    if (this.InitializeLayout != null)
                        this.InitializeLayout(sender, e);
            }
            catch (Exception ex)
            {

                throw ex;
            }


        }



    }
}
